/**
 * @param {number[]} nums
 * @return {number}
 */
var maxProduct = function (nums) {
  const dp = new Array(nums.length - 1).fill(0)
  dp[0] = nums[0]
  // if (nums.length > 1) dp[1] = dp[0] * nums[1]
  for (i = 1; i < nums.length; i++) {
    dp[i] = Math.max(nums[i]*dp[i-1],nums[i]*nums[i-1],nums[i])
  }
  // console.log(dp);
  return Math.max(...dp)
}

console.log(maxProduct([-2,3,-4]))
// -2 3